/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * modifyRes2.java
 *
 * Created on 27 Φεβ 2012, 6:28:36 μμ
 */
package handax.GUI;

import handax.controller.DBManager;
import handax.entities.Restaurant;
import handax.utilities.Utils;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.ImageObserver;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author Μιχάλης
 */
public class modifyRes2 extends javax.swing.JFrame {

    //αναφορά τύπου modifyRes
    private modifyRes root;
    
    //μεταβλητή τύπου int
    private int row;
    
    //δημιουργία DBManager για επικοινωνία με την βάση
    DBManager db =new DBManager();
    
    //Δημιουργία entity 
    Restaurant a =new Restaurant();
        
    /** Creates new form modifyRes2 */
    public modifyRes2() {
        initComponents();
        
        //απενεργοποίηση κουμπιού εισαγωγής
        importButton.setEnabled(false);
        
        //απενεργοποίηση κουμπιού τροποποίησης
        modifyButton.setEnabled(false);
        
        //απενεργοποίηση κουμπιού διαγραφής
        deleteButton.setEnabled(false);
    }

    //μέθοδος ορισμού αρχικού παραθύρου
     public void setRoot(modifyRes root){
        this.root=root;
    }
    
     //μέθοδος που ορίζει την επιλεγμένη σειρά από τον πίνακα
     //των εστιατορίων από το προηγούμενο παράθυρο
    public void setSelectedRow(int row){
        this.row=row;
    }
    
     
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        headerPanel = new javax.swing.JPanel();
        headerLabel = new javax.swing.JLabel();
        menuPanel = new javax.swing.JPanel();
        importButton = new javax.swing.JButton();
        modifyButton = new javax.swing.JButton();
        deleteButton = new javax.swing.JButton();
        backButton = new javax.swing.JButton();
        dataPanel = new javax.swing.JPanel();
        nameLabel = new javax.swing.JLabel();
        nameTextField = new javax.swing.JTextField();
        addressLabel = new javax.swing.JLabel();
        addressTextField = new javax.swing.JTextField();
        areaLabel = new javax.swing.JLabel();
        areaComboBox = new javax.swing.JComboBox();
        phoneLabel = new javax.swing.JLabel();
        phoneTextField = new javax.swing.JTextField();
        categoryLabel = new javax.swing.JLabel();
        categoryComboBox = new javax.swing.JComboBox();
        infoLabel = new javax.swing.JLabel();
        infoTextField = new javax.swing.JTextField();
        descrLabel = new javax.swing.JLabel();
        descrTextField = new javax.swing.JTextField();
        priceLabel = new javax.swing.JLabel();
        priceComboBox = new javax.swing.JComboBox();
        photoLabel = new javax.swing.JLabel();
        addPhotoButton = new javax.swing.JButton();
        deletePhotoButton = new javax.swing.JButton();
        imageLabel = new javax.swing.JLabel();
        updateButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(handax.HandaxApp.class).getContext().getResourceMap(modifyRes2.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N

        headerPanel.setName("headerPanel"); // NOI18N

        headerLabel.setIcon(resourceMap.getIcon("headerLabel.icon")); // NOI18N
        headerLabel.setText(resourceMap.getString("headerLabel.text")); // NOI18N
        headerLabel.setName("headerLabel"); // NOI18N

        menuPanel.setBackground(resourceMap.getColor("menuPanel.background")); // NOI18N
        menuPanel.setName("menuPanel"); // NOI18N

        importButton.setText(resourceMap.getString("importButton.text")); // NOI18N
        importButton.setName("importButton"); // NOI18N

        modifyButton.setText(resourceMap.getString("modifyButton.text")); // NOI18N
        modifyButton.setName("modifyButton"); // NOI18N

        deleteButton.setText(resourceMap.getString("deleteButton.text")); // NOI18N
        deleteButton.setName("deleteButton"); // NOI18N

        backButton.setText(resourceMap.getString("backButton.text")); // NOI18N
        backButton.setName("backButton"); // NOI18N
        backButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout menuPanelLayout = new javax.swing.GroupLayout(menuPanel);
        menuPanel.setLayout(menuPanelLayout);
        menuPanelLayout.setHorizontalGroup(
            menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, menuPanelLayout.createSequentialGroup()
                .addContainerGap(17, Short.MAX_VALUE)
                .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(backButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(deleteButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(modifyButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(importButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        menuPanelLayout.setVerticalGroup(
            menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(menuPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(importButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(modifyButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(deleteButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(backButton)
                .addContainerGap(392, Short.MAX_VALUE))
        );

        dataPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("dataPanel.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("dataPanel.border.titleFont"))); // NOI18N
        dataPanel.setName("dataPanel"); // NOI18N

        nameLabel.setFont(resourceMap.getFont("areaLabel.font")); // NOI18N
        nameLabel.setText(resourceMap.getString("nameLabel.text")); // NOI18N
        nameLabel.setName("nameLabel"); // NOI18N

        nameTextField.setText(resourceMap.getString("nameTextField.text")); // NOI18N
        nameTextField.setName("nameTextField"); // NOI18N

        addressLabel.setFont(resourceMap.getFont("areaLabel.font")); // NOI18N
        addressLabel.setText(resourceMap.getString("addressLabel.text")); // NOI18N
        addressLabel.setName("addressLabel"); // NOI18N

        addressTextField.setText(resourceMap.getString("addressTextField.text")); // NOI18N
        addressTextField.setName("addressTextField"); // NOI18N

        areaLabel.setFont(resourceMap.getFont("areaLabel.font")); // NOI18N
        areaLabel.setText(resourceMap.getString("areaLabel.text")); // NOI18N
        areaLabel.setName("areaLabel"); // NOI18N

        areaComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { ".", "1.Κνωσσός", "2. Αρκαλοχώρι", "3. Ζαρός", "4. Μοίρες", "5. Μάλια", "6. Αρχάνες", "7. Αρχάνεςι", "8. Αρχάνες", "9. Αρχάνες", "10. Αρχάνες" }));
        areaComboBox.setName("areaComboBox"); // NOI18N

        phoneLabel.setFont(resourceMap.getFont("areaLabel.font")); // NOI18N
        phoneLabel.setText(resourceMap.getString("phoneLabel.text")); // NOI18N
        phoneLabel.setName("phoneLabel"); // NOI18N

        phoneTextField.setText(resourceMap.getString("phoneTextField.text")); // NOI18N
        phoneTextField.setName("phoneTextField"); // NOI18N

        categoryLabel.setFont(resourceMap.getFont("areaLabel.font")); // NOI18N
        categoryLabel.setText(resourceMap.getString("categoryLabel.text")); // NOI18N
        categoryLabel.setName("categoryLabel"); // NOI18N

        categoryComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { ".", "1.Ελληνική Κουζίνα", "2.Ιταλική Κουζίνα", "3.Κινέζικη Κουζίνα", "4.Μεσογειακή Κουζίνα", "5.Ουζερί", "6.Μεζεδοπωλείο", "7.Ψαροταβέρνα", "8.Ταβέρνα", "9.Bar-Restaurant" }));
        categoryComboBox.setName("categoryComboBox"); // NOI18N

        infoLabel.setFont(resourceMap.getFont("areaLabel.font")); // NOI18N
        infoLabel.setText(resourceMap.getString("infoLabel.text")); // NOI18N
        infoLabel.setName("infoLabel"); // NOI18N

        infoTextField.setText(resourceMap.getString("infoTextField.text")); // NOI18N
        infoTextField.setName("infoTextField"); // NOI18N

        descrLabel.setFont(resourceMap.getFont("areaLabel.font")); // NOI18N
        descrLabel.setText(resourceMap.getString("descrLabel.text")); // NOI18N
        descrLabel.setName("descrLabel"); // NOI18N

        descrTextField.setText(resourceMap.getString("descrTextField.text")); // NOI18N
        descrTextField.setName("descrTextField"); // NOI18N
        descrTextField.setScrollOffset(7);

        priceLabel.setFont(resourceMap.getFont("areaLabel.font")); // NOI18N
        priceLabel.setText(resourceMap.getString("priceLabel.text")); // NOI18N
        priceLabel.setName("priceLabel"); // NOI18N

        priceComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { ".", "1.12€ - 20€", "2.15€ - 20€", "3.15€ - 25€", "4.20€ - 30€", "5.20€ - 35€", "6.35€ - 50€" }));
        priceComboBox.setName("priceComboBox"); // NOI18N

        photoLabel.setFont(resourceMap.getFont("areaLabel.font")); // NOI18N
        photoLabel.setText(resourceMap.getString("photoLabel.text")); // NOI18N
        photoLabel.setName("photoLabel"); // NOI18N

        addPhotoButton.setText(resourceMap.getString("addPhotoButton.text")); // NOI18N
        addPhotoButton.setName("addPhotoButton"); // NOI18N
        addPhotoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addPhotoButtonActionPerformed(evt);
            }
        });

        deletePhotoButton.setText(resourceMap.getString("deletePhotoButton.text")); // NOI18N
        deletePhotoButton.setName("deletePhotoButton"); // NOI18N
        deletePhotoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deletePhotoButtonActionPerformed(evt);
            }
        });

        imageLabel.setText(resourceMap.getString("imageLabel.text")); // NOI18N
        imageLabel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        imageLabel.setName("imageLabel"); // NOI18N

        javax.swing.GroupLayout dataPanelLayout = new javax.swing.GroupLayout(dataPanel);
        dataPanel.setLayout(dataPanelLayout);
        dataPanelLayout.setHorizontalGroup(
            dataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dataPanelLayout.createSequentialGroup()
                .addGap(60, 60, 60)
                .addComponent(photoLabel)
                .addGap(18, 18, 18)
                .addComponent(imageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(dataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(addPhotoButton)
                    .addComponent(deletePhotoButton))
                .addContainerGap(94, Short.MAX_VALUE))
            .addGroup(dataPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(dataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(priceLabel)
                    .addComponent(descrLabel)
                    .addComponent(infoLabel)
                    .addComponent(categoryLabel)
                    .addComponent(phoneLabel)
                    .addComponent(areaLabel)
                    .addComponent(addressLabel)
                    .addComponent(nameLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(dataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(dataPanelLayout.createSequentialGroup()
                        .addComponent(priceComboBox, 0, 322, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(dataPanelLayout.createSequentialGroup()
                        .addComponent(descrTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(dataPanelLayout.createSequentialGroup()
                        .addComponent(infoTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(dataPanelLayout.createSequentialGroup()
                        .addComponent(categoryComboBox, 0, 322, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(dataPanelLayout.createSequentialGroup()
                        .addComponent(phoneTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(dataPanelLayout.createSequentialGroup()
                        .addComponent(areaComboBox, 0, 322, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(dataPanelLayout.createSequentialGroup()
                        .addComponent(nameTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE)
                        .addGap(20, 20, 20))
                    .addGroup(dataPanelLayout.createSequentialGroup()
                        .addComponent(addressTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        dataPanelLayout.setVerticalGroup(
            dataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dataPanelLayout.createSequentialGroup()
                .addGroup(dataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(dataPanelLayout.createSequentialGroup()
                        .addGap(352, 352, 352)
                        .addGroup(dataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(priceLabel)
                            .addComponent(priceComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(17, 17, 17)
                        .addGroup(dataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(dataPanelLayout.createSequentialGroup()
                                .addComponent(addPhotoButton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(deletePhotoButton))
                            .addComponent(photoLabel)
                            .addComponent(imageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(dataPanelLayout.createSequentialGroup()
                        .addGroup(dataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(nameLabel)
                            .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(dataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(addressLabel)
                            .addComponent(addressTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(dataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(areaLabel)
                            .addComponent(areaComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(dataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(phoneLabel)
                            .addComponent(phoneTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(dataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(categoryLabel)
                            .addComponent(categoryComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(26, 26, 26)
                        .addGroup(dataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(infoLabel)
                            .addComponent(infoTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(31, 31, 31)
                        .addGroup(dataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(descrLabel)
                            .addComponent(descrTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(12, Short.MAX_VALUE))
        );

        updateButton.setText(resourceMap.getString("updateButton.text")); // NOI18N
        updateButton.setName("updateButton"); // NOI18N
        updateButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                updateButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout headerPanelLayout = new javax.swing.GroupLayout(headerPanel);
        headerPanel.setLayout(headerPanelLayout);
        headerPanelLayout.setHorizontalGroup(
            headerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(headerPanelLayout.createSequentialGroup()
                .addComponent(menuPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(dataPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(30, Short.MAX_VALUE))
            .addGroup(headerPanelLayout.createSequentialGroup()
                .addComponent(headerLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 665, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, headerPanelLayout.createSequentialGroup()
                .addContainerGap(463, Short.MAX_VALUE)
                .addComponent(updateButton)
                .addGap(187, 187, 187))
        );
        headerPanelLayout.setVerticalGroup(
            headerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(headerPanelLayout.createSequentialGroup()
                .addComponent(headerLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(headerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(dataPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 525, Short.MAX_VALUE)
                    .addComponent(menuPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(9, 9, 9)
                .addComponent(updateButton))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(headerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(headerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed
        
        //εκκαθάριση των vector του αρχικού παραθύρου
        root.clearData();
        
        //ανανέωση του πίνακα με τα εστιατόρια προς τροποποίηση
        root.insertRows(); 
        
        //ορισμός του αρχικού παραθύρου ως ορατό
        root.setVisible(true);
        
        //κατέστρεψε τον εαυτό σου
        dispose();
    }//GEN-LAST:event_backButtonActionPerformed

    //"Γέμισμα" ονομασίας επιλεγμένου εστιατορίου
    public void setNameTextField(String name) {
        nameTextField.setText(name);
    }
    
    //"Γέμισμα" διεύθυνσης επιλεγμένου εστιατορίου 
     public void setAddressTextField(String address) {
        addressTextField.setText(address);
    }
    
     //Επιλογή περιοχής επιλεγμένου εστιατορίου
     public void setAreaComboBox(int area) {
        areaComboBox.setSelectedIndex(area);
    }
     
     //Επιλογή κατηγορίας επιλεγμένου εστιατορίου
     public void setCategoryCombobox(int categ){
         categoryComboBox.setSelectedIndex(categ);
     }
     
     //"Γέμισμα" τηλεφώνου επιλεγμένου εστιατορίου
     public void setPhoneTextField(String phone) {
        phoneTextField.setText(phone);
    }
     
     //"Γέμισμα" πληροφοριών επιλεγμένου εστιατορίου
     public void setInfoTextField(String info){
          infoTextField.setText(info);
      }
     
     //"Γέμισμα" περιγραφής επιλεγμένου εστιατορίου
     public void setDescrTextField(String descr){
          descrTextField.setText(descr);
      }
     
     //Επιλογή εύρους τιμής επιλεγμένου εστιατορίου
     public void setPriceComboBox(int price){
          priceComboBox.setSelectedIndex(price);
      }
     
     //"Γέμισμα" φωτογραφίας επιλεγμένου εστιατορίου
     public void setImageLabel(String dest){
            
            //Αν δεν υπάρχει μονοπάτι για φώτο τότε δήλωσε την DEFAULT
            if(dest==null){
                dest="rest_photos\\DEFAULT.jpg";
                }
            
            //δημιουργία εικόνας από τον προορισμό
            Image img=Toolkit.getDefaultToolkit().getImage(dest);
            
            //δημιουργία εικονιδίου από την εικόνα
            ImageIcon i=new ImageIcon(img);
            
            //δημιουργία ImageObserver
            ImageObserver io = null;
            
            //δημιουργία καινούριου εικονιδίου 
            //με προσαρμοσμένη διάσταση
            Icon ic=Utils.scale(img, 150.0, io);
            
            //τοποθέτηση εικονιδίου στο jLabel
            imageLabel.setIcon(ic);
            
            //ορισμός photo εστιατορίου
            a.setPhoto(dest);
     }
    
   
    private void updateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateButtonActionPerformed
        
     
      try{
          
          //Στοιχεία προς ενημέρωση
          String name=nameTextField.getText().trim();
          String address=addressTextField.getText().trim();
          int area=areaComboBox.getSelectedIndex();
          String phone=phoneTextField.getText().trim();
          int categ=categoryComboBox.getSelectedIndex();
          String info=infoTextField.getText().trim();
          String descr=descrTextField.getText().trim();
          int price=priceComboBox.getSelectedIndex();
           
         
          
          //ορισμός των καινούριων στοιχείων
                     a.setRestName(name);
                     a.setAddress(address);
                     a.setPhone(phone);
                     a.setArea(area);
                     a.setCategory(categ);
                     a.setInfo(info);
                     a.setDescr(descr);
                     a.setPrice(price);
                     a.setId(db.retrieveAllRests().get(row).getId());
  
                     
                     //έλεγχος αν έχουν συμπληρωθεί ολα τα πεδία        
                     if("".equals(name) || "".equals(address)|| "".equals(phone)
                             ||"".equals(info) ||"".equals(descr) ||area==0 ||
                             categ==0 || price==0){
                         throw new Exception("Πρέπει να συμπληρωθούν όλα τα πεδία!");   
                            }
                     
                    //Μήνυμα επιβεβαίωσης διαγραφής
                    int result =JOptionPane.showConfirmDialog(new JFrame(),"Επιβεβαίωση Τροποποίησης?",
                                                                   "",
                                                                   JOptionPane.YES_NO_OPTION);
            
                    //Αν επιλέξει ΝΑΙ
                    if (result==JOptionPane.YES_OPTION){
                            
                            //ενημέρωση εστιατορίου
                            db.updateRestaurant(a);
                            
                            //μήνυμα επιτυχίας
                            JOptionPane.showMessageDialog(new JFrame(), "Επιτυχής ενημέρωση");
                    }
          
         }
      catch (Exception ex){
          JOptionPane.showMessageDialog(new JFrame(), "Πρέπει να συμπληρωθούν όλα τα πεδία!");
      }
    }//GEN-LAST:event_updateButtonActionPerformed

    private void addPhotoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addPhotoButtonActionPerformed

            //Δημιουργία ενός jFileChooser
            JFileChooser fl=new JFileChooser();
            
            //άνοιγμα παραθύρου επιλογής αρχείου
            int returnval=fl.showOpenDialog(this);
            
            //αν επιλεχθεί εικόνα τότε ενημερώνει το imgLabel
            //και το path στην βάση
            if(returnval==fl.APPROVE_OPTION){
            //αποθήκευση προορισμού του αρχείου
            String path=fl.getSelectedFile().getAbsolutePath();
   
            //ορισμός της καινούριας φώτο
            setImageLabel(path);
            }
    }//GEN-LAST:event_addPhotoButtonActionPerformed

    private void deletePhotoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deletePhotoButtonActionPerformed
        
            //εκκαθάριση του jLabel
            imageLabel.setIcon(null);
        
            //ορισμός default φωτογραφίας
            a.setPhoto("rest_photos\\DEFAULT.jpg");
    }//GEN-LAST:event_deletePhotoButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(modifyRes2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(modifyRes2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(modifyRes2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(modifyRes2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new modifyRes2().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addPhotoButton;
    private javax.swing.JLabel addressLabel;
    private javax.swing.JTextField addressTextField;
    private javax.swing.JComboBox areaComboBox;
    private javax.swing.JLabel areaLabel;
    private javax.swing.JButton backButton;
    private javax.swing.JComboBox categoryComboBox;
    private javax.swing.JLabel categoryLabel;
    private javax.swing.JPanel dataPanel;
    private javax.swing.JButton deleteButton;
    private javax.swing.JButton deletePhotoButton;
    private javax.swing.JLabel descrLabel;
    private javax.swing.JTextField descrTextField;
    private javax.swing.JLabel headerLabel;
    private javax.swing.JPanel headerPanel;
    private javax.swing.JLabel imageLabel;
    private javax.swing.JButton importButton;
    private javax.swing.JLabel infoLabel;
    private javax.swing.JTextField infoTextField;
    private javax.swing.JPanel menuPanel;
    private javax.swing.JButton modifyButton;
    private javax.swing.JLabel nameLabel;
    private javax.swing.JTextField nameTextField;
    private javax.swing.JLabel phoneLabel;
    private javax.swing.JTextField phoneTextField;
    private javax.swing.JLabel photoLabel;
    private javax.swing.JComboBox priceComboBox;
    private javax.swing.JLabel priceLabel;
    private javax.swing.JButton updateButton;
    // End of variables declaration//GEN-END:variables
}
